package com.sz.businessrecommend.dao.impl;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import java.util.HashMap;

import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;


import com.sz.businessrecommend.dao.IBusinessRecommendDAO;

import com.sz.common.SZUtility;

import com.sz.common.ICommonDAO;



public class BusinessRecommendDAO extends SqlMapClientDaoSupport implements IBusinessRecommendDAO{
	
	protected final Log logger = LogFactory.getLog(getClass());
	
	private ICommonDAO commonDAO = null;
	
	public ICommonDAO getCommonDAO() {
		return commonDAO;
	}

	public void setCommonDAO(ICommonDAO commonDAO) {
		this.commonDAO = commonDAO;
	}

	@SuppressWarnings("unchecked")
	public List queryBusiness(Map map) throws Exception {		
		List list = getSqlMapClient().queryForList("businessrecommend_sqlmap.query_Business", map);
		return addition(list);
	}
	

	
	@SuppressWarnings("unchecked")
	public long queryBusinessCount(Map map) throws Exception {
		Map r = (Map)getSqlMapClient().queryForObject("businessrecommend_sqlmap.query_BusinessCount", map);
		return Long.parseLong(r.get("COUNT").toString());
	}
	
	@SuppressWarnings("unchecked")
	public List queryBusinessPage(Map map) throws Exception {
		List list = getSqlMapClient().queryForList("businessrecommend_sqlmap.query_BusinessPage", map);
		return addition(list);
	}
	
	
	@SuppressWarnings("unchecked")
	public List queryRecommend(Map map) throws Exception {		
		List list = getSqlMapClient().queryForList("businessrecommend_sqlmap.query_Recommend", map);
		return addition(list);
	}
	
	@SuppressWarnings("unchecked")
	public long queryRecommendCount(Map map) throws Exception {
		Map r = (Map)getSqlMapClient().queryForObject("businessrecommend_sqlmap.query_RecommendCount", map);
		return Long.parseLong(r.get("COUNT").toString());
	}
	
	@SuppressWarnings("unchecked")
	public List queryRecommendPage(Map map) throws Exception {
		List list = getSqlMapClient().queryForList("businessrecommend_sqlmap.query_RecommendPage", map);
		return addition(list);
	}
	
	
	@SuppressWarnings("unchecked")
	public List queryRecommendAs(Map map) throws Exception {		
		List list = getSqlMapClient().queryForList("businessrecommend_sqlmap.query_RecommendAs", map);
		return addition(list);
	}
	
	@SuppressWarnings("unchecked")
	public long queryRecommendCountAs(Map map) throws Exception {
		Map r = (Map)getSqlMapClient().queryForObject("businessrecommend_sqlmap.query_RecommendCountAs", map);
		return Long.parseLong(r.get("COUNT").toString());
	}
	
	@SuppressWarnings("unchecked")
	public List queryRecommendPageAs(Map map) throws Exception {
		List list = getSqlMapClient().queryForList("businessrecommend_sqlmap.query_RecommendPageAs", map);
		return addition(list);
	}
	
	
	@SuppressWarnings("unchecked")
	public long delRecommend(Map map) throws Exception {
		getSqlMapClient().update("businessrecommend_sqlmap.delete_Business_Recommend", map);
		return 1;
	}
	
	@SuppressWarnings("unchecked")
	public long addRecommend(Map map) throws Exception {
		getSqlMapClient().insert("businessrecommend_sqlmap.insert_Business_Recommend", map);
		return 1;
	}
	
	
	@SuppressWarnings("unchecked")	
	private List addition(List list) {		
		if(list == null) return null;
		return list;
	}

}
